package com.wanmait.baohan.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wanmait.baohan.mapper.DictionaryMapper;
import com.wanmait.baohan.pojo.Dictionary;
import com.wanmait.baohan.service.DictionaryService;
import com.wanmait.baohan.vo.KeyAndValueVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@Transactional(rollbackFor = Exception.class)
public class DictionaryServiceImpl implements DictionaryService {
    @Resource
    private DictionaryMapper dictionaryMapper;
    @Override
    public List<Dictionary> findAllInvoiceType() {
        return dictionaryMapper.findAllInvoiceType();
    }

    @Override
    public Dictionary selectByValue(Integer id) {
        return dictionaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Dictionary> selectByType(Integer i) {
        return dictionaryMapper.selectByType(i);
    }



    @Override
    public List<Map<String, Object>> getProductTypeA() {
        return dictionaryMapper.selectProductTypeA();
    }

    @Override
    public List<Map<String, Object>> getProductTypeB() {
        return dictionaryMapper.selectProductTypeB();
    }

    @Override
    public List<Map<String, Object>> getProductTypeC() {
        return dictionaryMapper.selectProductTypeC();
    }

    @Override
    public List<Map<String, Object>> getProductTypeD() {
        return dictionaryMapper.selectProductTypeD();
    }

    @Override
    public List<Map<String, Object>> getProductTypeE() {
        return dictionaryMapper.selectProductTypeE();
    }

    @Override
    public List<Map<String, Object>> selectBusinessContactsTypeA() {
        return dictionaryMapper.selectBusinessContactsTypeA();
    }

    @Override
    public List<Map<String, Object>> selectBusinessContactsTypeB() {
        return dictionaryMapper.selectBusinessContactsTypeB();
    }

    @Override
    public List<Map<String, Object>> getDemandTypeA() {
        return dictionaryMapper.getDemandTypeA();
    }

    @Override
    public List<Map<String, Object>> getDemandTypeB() {
        return dictionaryMapper.getDemandTypeB();
    }

    @Override
    public List<Map<String, Object>> getDemandTypeC() {
        return dictionaryMapper.getDemandTypeC();
    }

    @Override
    public List<Map<String, Object>> getDemandTypeD() {
        return dictionaryMapper.getDemandTypeD();
    }

    @Override
    public List<Map<String, Object>> getDemandTypeE() {
        return dictionaryMapper.getDemandTypeE();
    }


    /**
     * hxn
     * @return
     * 获取所有飞机坐席
     */
    @Override
    public List<Map<String, String>> getAirplaneSeat() {
        return dictionaryMapper.selectAirplaneSeat();
    }

    /**
     * hxn
     * @return
     * 获取所有火车坐席
     */
    @Override
    public List<Map<String, String>> getTrainSeat() {
        return dictionaryMapper.selectTrainSeat();
    }

    /**
     * hxn
     * @return
     * 获取所有高铁坐席等级
     * */
    @Override
    public List<Map<String, String>> getHighSpeedTrainSeat() {
        return dictionaryMapper.selectHighSpeedSeat();
    }

    /**
     * hxn
     * @return
     * 获取所有公交车坐席
     */
    @Override
    public List<Map<String, String>> getBusSeat() {
        return dictionaryMapper.selectBusSeat();
    }

    /**
     * hxn
     * @return
     * 获取所有可订酒店的类型
     */
    @Override
    public List<Map<String,String>> getBookingHotelProjectType() {
        return dictionaryMapper.selectBookingHotelProjectType();
    }

    /**
     * hxn
     * @return
     * 获取所有可派车的类型
     */
    @Override
    public List<Map<String, String>> getBookingCarProjectType() {
        return dictionaryMapper.selectBookingCarProjectType();
    }

    /**
     * hxn
     * @return
     * 获取所有可订票的类型
     */
    @Override
    public List<Map<String, String>> getBookingTicketProjectType() {
        return dictionaryMapper.selectBookingTicketProjectType();
    }

    /**
     * hxn
     * @return
     * 获取所有交通工具类型
     */
    @Override
    public List<Map<String, String>> getTransportType() {
        return dictionaryMapper.selectTransportType();
    }

    /**
     * hxn
     * @return
     * 获取所有产品品名
     */
   /* @Override
    public List<Map<String, Object>> getProducts() {
        return dictionaryMapper.selectAllProducts();
    }*/

    @Override
    public List<KeyAndValueVo> getTemplateTypes() {
        QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("`key`", "`value`").eq("dictionary_type_id", 36);
        List<Dictionary> dictionaries = dictionaryMapper.selectList(queryWrapper);
        List<KeyAndValueVo> keyAndValueVos = new ArrayList<>();
        dictionaries.forEach(dictionary -> {
            KeyAndValueVo keyAndValueVo = new KeyAndValueVo();
            keyAndValueVo.setKey(dictionary.getKey());
            keyAndValueVo.setValue(dictionary.getValue());
            keyAndValueVos.add(keyAndValueVo);
        });
        return keyAndValueVos;
    }

    @Override
    public List<KeyAndValueVo> getWorkLevel() {
        QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("`key`", "`value`").eq("dictionary_type_id", 38);
        List<Dictionary> dictionaries = dictionaryMapper.selectList(queryWrapper);
        List<KeyAndValueVo> keyAndValueVos = new ArrayList<>();
        dictionaries.forEach(dictionary -> {
            KeyAndValueVo keyAndValueVo = new KeyAndValueVo();
            keyAndValueVo.setKey(dictionary.getKey());
            keyAndValueVo.setValue(dictionary.getValue());
            keyAndValueVos.add(keyAndValueVo);
        });
        return keyAndValueVos;
    }

    @Override
    public List<KeyAndValueVo> getWorkload() {
        QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("`key`", "`value`").eq("dictionary_type_id", 37);
        List<Dictionary> dictionaries = dictionaryMapper.selectList(queryWrapper);
        List<KeyAndValueVo> keyAndValueVos = new ArrayList<>();
        dictionaries.forEach(dictionary -> {
            KeyAndValueVo keyAndValueVo = new KeyAndValueVo();
            keyAndValueVo.setKey(dictionary.getKey());
            keyAndValueVo.setValue(dictionary.getValue());
            keyAndValueVos.add(keyAndValueVo);
        });
        return keyAndValueVos;
    }

    @Override
    public List<KeyAndValueVo> getWorkTimes() {
        QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("`key`", "`value`").eq("dictionary_type_id", 39);
        List<Dictionary> dictionaries = dictionaryMapper.selectList(queryWrapper);
        List<KeyAndValueVo> keyAndValueVos = new ArrayList<>();
        dictionaries.forEach(dictionary -> {
            KeyAndValueVo keyAndValueVo = new KeyAndValueVo();
            keyAndValueVo.setKey(dictionary.getKey());
            keyAndValueVo.setValue(dictionary.getValue());
            keyAndValueVos.add(keyAndValueVo);
        });
        return keyAndValueVos;
    }
    @Override
    public List<Map<String, Object>> getProducts() {
        return dictionaryMapper.selectAllProducts();
    }
    @Override
    public List<Map<String, Object>> getAgentType() {
        return dictionaryMapper.getAgentType();
    }

    @Override
    public List<Map<String, Object>> getAcountTypeA() {
        return dictionaryMapper.getAcountTypeA();
    }

    @Override
    public List<Map<String, Object>> getAcountTypeB() {
        return dictionaryMapper.getAcountTypeB();
    }

    @Override
    public List<Map<String, Object>> getAcountTypeC() {
        return dictionaryMapper.getAcountTypeC();
    }
}
